/*
 * Public Credit Information Sharing Platform(PCISP).
 * Copyright (c) 2019-2020 jsxzkingdee and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * Please visit https://www.zhengxinsoft.com if you need additional information or have any questions.
 */

package com.platform.comm.jwt;

import com.platform.comm.constants.GlobalConstant;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

/**
 * Description: JWT Token 缓存实现
 *
 * @author libin created on 2020/5/14.
 */
@Component
public class JwtTokenStorageCache implements JwtTokenStorage {

    public static final String TOKEN_REDIS_KEY = GlobalConstant.BASE_REDIS_CACHE_PREFIX + "token";

    @CachePut(value = TOKEN_REDIS_KEY, key = "#userId")
    @Override
    public String put(String token, String userId) {
        return token;
    }

    @CacheEvict(value = TOKEN_REDIS_KEY, key = "#userId")
    @Override
    public void expire(String userId) {
    }

    @CachePut(value = TOKEN_REDIS_KEY, key = "#userId")
    @Override
    public String refresh(String token, String userId) {
        return token;
    }

    @Cacheable(value = TOKEN_REDIS_KEY, key = "#userId", condition = "#result != null ")
    @Override
    public String get(String userId) {
        return null;
    }
}
